import {
	listDictByCode
} from "@/common/apis/common.js"

const state = {
	// 年级
	gradeList: [],
	//用户来源
	user_resourceList:[]
}

const mutations = {
	setDic(state, obj) {
		state[obj.key] = obj.val
	}
}

const actions = {
	async fetchDayDic({
		state,
		commit
	}, obj) {
		if (state[obj.key].length > 0) {

		} else {
			let tampARR = []
			try {
				tampARR = (await listDictByCode({
					code: obj.code
				})).data;
			} catch (err) {
				tampARR = []
			}
			commit("setDic", {
				key: obj.key,
				val: tampARR
			})
		}
	}
}


export default {
	namespaced: true,
	state,
	mutations,
	actions
}
